package cn.tedu.epidemic.webapi.controller;

import cn.tedu.adminsystem.service.NoticeService;
import cn.tedu.community.commons.pojo.notice.vo.UserNoticeListItemVO;
import cn.tedu.community.commons.pojo.notice.vo.UserNoticeStandardVO;
import cn.tedu.community.commons.restful.JsonPage;
import cn.tedu.community.commons.restful.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 公告Controller
 */
@Api(tags = "公告控制器")
@RestController
@Slf4j
@Validated
@RequestMapping("/notice")
public class NoticeController {

    @DubboReference
    private NoticeService DubboService;

    @GetMapping("/{id:[0-9]+}/UserNoticeStandard")
    public JsonResult<UserNoticeStandardVO> getUserNoticeStandardById(@PathVariable Long id) {
        UserNoticeStandardVO standardVO = DubboService.getUserNoticeStandardById(id);
        return JsonResult.ok(standardVO);
    }

    @GetMapping("/{page:[0-9]+}/{pageSize:[0-9]+}/userNoticeList")
    public JsonResult<JsonPage<UserNoticeListItemVO>> getUserNoticeList(@PathVariable Integer page,
                                                                        @PathVariable Integer pageSize) {
        log.debug("查询公告到用户页面列表，页码是：{}，每页条数是：{}", page, pageSize);
        JsonPage<UserNoticeListItemVO> userNoticeList = DubboService.getUserNoticeList(page, pageSize);
        log.debug("查询公告到用户列表的数据是：{}", userNoticeList);
        return JsonResult.ok(userNoticeList);
    }

}
